function graph = import_yed(graph)

% ----------------------------------------------
% This function is designed to import a graph
% from a gml file.  
%
% USAGE:
% graph = import_yed(filename)
%
% CREDITS:
% This script was written by Victor Wong.
% ----------------------------------------------

graph.node_info = [];
graph.edge_info = [];

graph = openFile(graph);
text = graph.text;

key_i = 1;
nodes = 0;
nodes_i = 0;
edges = 0;
edges_i = 0;
data_i = 0;
i = 1;
for i=1:length(text)
    t = text{i};

    if strcmpi(t, 'node')
       nodes = 1;
       edges = 0;
       nodes_i = nodes_i+1;
    end
	if strcmpi(t, 'edge')    
    	nodes = 0;
        edges = 1;
        edges_i = edges_i+1;
    end
    double_tok = regexpi(t, '^(.*)\s+(.*)', 'tokens');
    if ~isempty(double_tok)
        prop = double_tok{1}{1};
        value = XMLchar(double_tok{1}{2}, 'Matlab');     
        if nodes == 1
            eval(['graph.node_info.' prop '{nodes_i} = ''' value ''';']); 
        end
        if edges == 1
            eval(['graph.edge_info.' prop '{edges_i} = ''' value ''';']); 
        end
    end    
end